package MyThread;

import java.util.concurrent.locks.ReentrantLock;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: AliceMana
 * Date: 2023-01-12
 * Time: 16:26
 */
public class ThreadDemo30 {
    public static void main(String[] args) {
        ReentrantLock reentrantLock = new ReentrantLock();
        boolean result = reentrantLock.tryLock();

        try {
            if (result) {
                // do something
            } else {
                // 啥都不做
            }
        } finally {
            if (result) {
                reentrantLock.unlock();
            }
        }
    }
}
